//
// Created by xili on 2024/8/30 20:19.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    int maxCoins(vector<int> &piles) {
        sort(piles.begin(), piles.end());
        int n = piles.size();
        int bob = n / 3;
        int ans = 0;
        for (int i = n - 2; i >= bob; i -= 2) {
            ans += piles[i];
        }
        return ans;
    }
};